package com.mall.auth.entity;

/**
 * OAuth2.0 提供商枚举
 */
public enum OAuth2Provider {
    WECHAT("wechat", "微信"),
    ALIPAY("alipay", "支付宝"),
    DOUYIN("douyin", "抖音"),
    QQ("qq", "QQ");

    private final String code;
    private final String name;

    OAuth2Provider(String code, String name) {
        this.code = code;
        this.name = name;
    }

    public String getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public static OAuth2Provider fromCode(String code) {
        for (OAuth2Provider provider : OAuth2Provider.values()) {
            if (provider.getCode().equals(code)) {
                return provider;
            }
        }
        throw new IllegalArgumentException("未知的OAuth2提供商: " + code);
    }
}